public class Solution10 {
    //组合总和4
    public int combinationSum4(int[] nums, int target) {
        int n = nums.length;
        int[] dp = new int[target+1];  //dp[i]表示凑成i，一共有多少种组合
        dp[0] = 1;
        for (int i = 1; i < target+1; i++) {
            for (int j = 1; j < n+1; j++) {
                if (i >= nums[j-1]) {
                    dp[i] += dp[i-nums[j-1]];
                }
            }
        }
        return dp[target];
    }
}
